<template>
  <div id="app">
    <a @click="left" :class="{selected:isActive}">Left</a> &nbsp;|
    <a @click="right" :class="{selected:!isActive}">Right</a>
    <hr>
    <!-- <Left></Left>
    <Right></Right> -->
    <keep-alive include="Left">
      <component :is="componentName"></component>
    </keep-alive>
  </div>
</template>

<script>
import Left from './components/Left.vue'
import Right from './components/Right.vue'

export default {
  name: 'App',
  components: {
    Left,
    Right
  },
  data:function () {
    return {
      componentName:'Left',
      isActive:true
    }
  },
  methods:{
    left(){
      this.componentName = 'Left';
      this.isActive = true;
    },
    right(){
      this.componentName = 'Right';
      this.isActive = false;
    }
  }
}
</script>

<style>
#app {
  font-size: 30px;
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: #2c3e50;
  margin-top: 60px;
}

#app div {
  float: left;
  outline: 1px solid red;
  margin-right: 20px;
  padding: 20px;
}

.selected{
  color: red;
  text-decoration: underline;
}
</style>
